package com.gkd.mapper;

import com.gkd.pojo.Employee;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Mapper
@Component
@Transactional
@Repository
public interface EmployeeMapper {
    @Select("select * from mybatis.employees")
    List<Employee> queryPageAll();

    @Select("select * from mybatis.employees")
    List<Employee> queryEmployeeAll();

    @Select("select * from mybatis.employees where id = #{id}")
    Employee selectEmployeeById(int id);

    @Delete("delete from mybatis.employees where id = #{id}")
    void deleteEmployee(int id);

    @Insert("INSERT into mybatis.employees " +
            "(lastName, email, gender , birth , de_id ) " +
            "values ( #{lastName},#{email},#{gender},#{birth},#{de_id})")
    void insertEmployee(Employee employee);

    @Update("update mybatis.employees " +
            "set lastName = #{lastName},email = #{email},gender = #{gender},birth = #{birth},de_id = #{de_id} " +
            "where id = #{id}")
    void updateEmployeeById(Employee employee);

    @Select("select id from mybatis.employees")
    List<Integer> selectEmployeeForId();

}
